<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>et</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
    <meta name="author" content="Muhammad Usman">
<%@include file="/commons/commonJs.jsp"%>

<script type="text/javascript">
$(document).ready(function(){
	ajaxDiv(false, '', '<%=basePath%>mgt/classTable/queryClassTableList.do','' , initClassTable2);
});

function forQueryWeekClass(){
	$("#forClassDate").val("");
	$("#queryWeekClass").modal();
}
function queryWeekClass(){
	var flag1=myValidate('forClassDate',true);
	if(flag1){
		var classDate=$("#forClassDate").val();
		
	       ajaxDiv(false, '', '<%=basePath%>mgt/classTable/queryClassTableList.do','{classDate:"'+classDate+'"}' , initClassTable2);
	       $("#queryWeekClass").modal('hide');
       }
}

function initClassTable2(data,divId){
	var classStartTime="0";
	var classEndTime="0";
	var list = data["classTableList"];
	var weekDateList = data["weekDateList"];
	$("#tb_weekClass").html("");
	$("#tr_classDate").html("<th></th>");
	if(weekDateList.length>0){
		for ( var i = 0; i < weekDateList.length; i++) {
			$("#tr_classDate").append('<th>'+weekDateList[i]+'</th>');
		}
	}
	
	
	if(list.length>0){
	for ( var i = 0; i < list.length; i++) {
		var item = list[i];
		if(item.id>0){
			var classDate=item.classDate;
			if(item.classStartTime!=classStartTime && item.classEndTime!=classEndTime){
				classStartTime=item.classStartTime;
				classEndTime=item.classEndTime;
				var count = i +1;
		        
				
				$("#tb_weekClass").append('<tr id="tr_'+count+'">'+
				   '<input type="hidden" id="classStartTime'+count+'" value="'+classStartTime+'">'+
				   '<input type="hidden" id="classEndTime'+count+'" value="'+classEndTime+'">'+
		           '<td>'+classStartTime+'<br>&nbsp;&nbsp;&nbsp;&nbsp;|<br>'+classEndTime+'</td>'+
		           '<td class="center" id="td_'+count+'_1"></td>'+
		           '<td class="center" id="td_'+count+'_2"></td>'+
		           '<td class="center" id="td_'+count+'_3"></td>'+
		           '<td class="center" id="td_'+count+'_4"></td>'+
		           '<td class="center" id="td_'+count+'_5"></td>'+
		           '<td class="center" id="td_'+count+'_6"></td>'+
		           '<td class="center" id="td_'+count+'_7"></td>'+
		       '</tr>');
			}
			
			var date = new Date(classDate).getDay();
	        if(date==0){
	       		date=7;
	        }
			var arr=new Array();
			//注split可以用字符或字符串分割
			var level = "";
			var levelType=item.levelType;
			var classLevel=item.classLevel;
			if(levelType=="all"){
				level = "all level";
			}else if(levelType=="equals"){
				arr=classLevel.split(',');
				level = "level"+arr[1];
			}else if(levelType=="above"){
				arr=classLevel.split(',');
				level = "above level"+arr[1];
			}else{
				arr=classLevel.split(',');
				level = "level"+arr[1]+"-"+arr[arr.length-2];
			}
			$("#td_"+count+"_"+date).html('课名：'+item.classInfoName+'<br>教师：'+item.classTeacherName+'<br>班级：'+item.classAddr+'<br>级别：'+level+'<br>人数：'+item.orderClassNum+'/'+item.studentNum+'<br>'+
	            '<button class="btn btn-success btn-xs" onclick="forClassTableShow('+item.id+')">view</button>');
			
		}
	}
	}
}




function forClassTableShow(id){
	ajaxDiv(false, 'classTableShow', '<%=basePath%>mgt/classTable/toClassTableShow.do', '{id:'+id+'}', forClassTableShow2);
	$("#classTableShow").modal();
}
function forClassTableShow2(data,tdId){
	$("#show_classInfoName").val(data.classInfoName);
	$("#show_classTeacherName").val(data.classTeacherName);
	$("#show_classAddr").val(data.classAddr);
	$("#show_studentNum").val(data.studentNum);
	$("#show_orderClassNum").val(data.orderClassNum);
	$("#show_createUser").val(data.createUser);
	$("#show_createTime").val(data.createTime);
	$("#show_updateUser").val(data.updateUser);
	$("#show_updateTime").val(data.updateTime);
	$("#show_studentNames").val(data.studentNames);
	
	var arr=new Array();
	//注split可以用字符或字符串分割
	var level = "";
	var levelType=data.levelType;
	var classLevel=data.classLevel;
	if(levelType=="all"){
		level = "all level";
	}else if(levelType=="equals"){
		arr=classLevel.split(',');
		level = "level"+arr[1];
	}else if(levelType=="above"){
		arr=classLevel.split(',');
		level = "above level"+arr[1];
	}else{
		arr=classLevel.split(',');
		level = "level"+arr[1]+"-"+arr[arr.length-2];
	}
	$("#show_classLevel").val(level);
}









</script>
</head>

<body>

            <!-- content starts -->
                <div>
        <ul class="breadcrumb">
            <li>
                <a href="javascript:skipPage('<%=basePath%>mgt/sys/content.do')">主页</a>
            </li>
            <li>
                <a href="#">往期课表</a>
            </li>
        </ul>
    </div>


        



    <div class="row">
    <div class="box col-md-12">
    <div class="box-inner">
    <div class="box-header well" data-original-title="">
        <h2><i class="glyphicon glyphicon-user"></i> 往期课表</h2>
		<a class="btn btn-round btn-success" href="javascript:forQueryWeekClass();" style="font-size:10px;float:right">
        		<i class="glyphicon glyphicon-eye-open icon-white"></i>选择时间</a>
    </div>
    <div class="box-content">
    <table class="table table-bordered table-striped table-condensed" >
    <thead>
    <tr id="tr_classDate">
    </tr>
    <tr>
    	<th>时间</th>
        <th>Mon</th>
        <th>Tue</th>
        <th>Wed</th>
        <th>Thu</th>
        <th>Fri</th>
        <th>Sat</th>
        <th>Sun</th>
    </tr>
    </thead>
    <tbody id="tb_weekClass">
    </tbody>
    </table>
    
    
    
    </div>
    </div>
    </div>
    <!--/span-->

    </div><!--/row-->





	<div class="modal fade" id="queryWeekClass" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">

        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <h3>选择日期</h3>
                </div>
                <div class="modal-body">
                	<fieldset>
                    <div class="form-group col-md-12">
                    <label class="control-label" for="forClassDate">课程日期</label><span id="sp_forClassDate" ></span>
                    <input type="text" class="form-control" readonly="readonly" id="forClassDate" onclick="new WdatePicker({el:$dp.$('bftime'),dateFmt:'yyyy-MM-dd'})">
                </div>
				  	
				</fieldset>  
                </div>
                <div class="modal-footer">
                    <a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
                    <a class="btn btn-primary" href="javascript:queryWeekClass();">确定</a>
                </div>
            </div>
        </div>
    </div>



	<div class="modal fade" id="classTableShow" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">

        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <h3>课程信息</h3>
                </div>
                <div class="modal-body">
                	<fieldset>
                	
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_classInfoName">课名</label>
                    <input type="text" class="form-control" name="show_classInfoName" value="" id="show_classInfoName">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_classTeacherName">教师</label>
                    <input type="text" class="form-control" name="show_classTeacherName" value="" id="show_classTeacherName">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_classLevel">级别</label>
                    <input type="text" class="form-control" name="show_classLevel" value="" id="show_classLevel">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_classAddr">班级</label>
                    <input type="text" class="form-control" name="show_classAddr" value="" id="show_classAddr">
                </div>
                
				  	<div class="form-group col-md-12">
                    <label class="control-label" for="show_studentNum">限定人数</label>
                    <input type="text" class="form-control" name="show_studentNum" value="" id="show_studentNum">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_orderClassNum">已报人数</label>
                    <input type="text" class="form-control" name="show_orderClassNum" value="" id="show_orderClassNum">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_studentNames">已报人员</label>
                    <input type="text" class="form-control" name="show_studentNames" value="" id="show_studentNames">
                </div>	
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_createUser">创建人</label>
                    <input type="text" class="form-control" name="show_createUser" value="" id="show_createUser">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_createTime">创建时间</label>
                    <input type="text" class="form-control" name="show_createTime" value="" id="show_createTime">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_updateUser">修改人</label>
                    <input type="text" class="form-control" name="show_updateUser" value="" id="show_updateUser">
                </div>
                <div class="form-group col-md-12">
                    <label class="control-label" for="show_updateTime">修改时间</label>
                    <input type="text" class="form-control" name="show_updateTime" value="" id="show_updateTime">
                </div>	
                	
				  	
				</fieldset>  
                </div>
                <div class="modal-footer">
                    <a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
                    <!-- <a href="#" class="btn btn-primary" data-dismiss="modal">Save changes</a> -->
                </div>
            </div>
        </div>
    </div>
    
    <!-- content ends -->


</body>
</html>
